package com.gsafety.wellsfort.controller.knowledge;

import com.gsafety.wellsfort.common.util.ApiResponse;
import com.gsafety.wellsfort.domain.dto.courseware.CoursewareDTO;
import com.gsafety.wellsfort.domain.dto.courseware.CoursewareQueryDTO;
import com.gsafety.wellsfort.domain.dto.ids.CoursewareIdDTO;
import com.gsafety.wellsfort.domain.vo.CoursewareVO;
import com.gsafety.wellsfort.service.knowledge.CoursewareService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "课件管理",description = "课件管理接口")
@RestController
@Slf4j
@RequestMapping("/api/courseware")
public class CoursewareController {
    @Autowired
    private CoursewareService coursewareService;
    @ApiOperation(value="保存课件")
    @PostMapping("/save")
    public ApiResponse<CoursewareDTO>  saveCourseware(@RequestBody CoursewareDTO coursewareDto){
        return coursewareService.saveCourseware(coursewareDto);
    }

    @ApiOperation(value="删除课件")
    @PostMapping("/remove")
    public ApiResponse deleteCourseware(@RequestBody CoursewareIdDTO idDto){
        return coursewareService.deleteByCoursewareId(idDto.getCoursewareId());
    }

    @ApiOperation(value="查看或编辑课件")
    @PostMapping("/get")
    public ApiResponse<CoursewareVO> getCourseware(@RequestBody CoursewareIdDTO idDto){
        return coursewareService.getCourseware(idDto.getCoursewareId());
    }

    @ApiOperation(value="查询课件")
    @PostMapping("/list")
    public ApiResponse<List<CoursewareVO>> findByPageParams(@RequestBody CoursewareQueryDTO dtoParams){
        return coursewareService.findByPageParams(dtoParams);
    }

}
